package RenRen;
import java.io.BufferedReader;
import java.io.IOException;  
import java.io.InputStreamReader;  
import java.io.OutputStream;  
import java.net.HttpURLConnection;  
import java.net.MalformedURLException;  
import java.net.URL;  
import java.net.URLConnection;  

public class XiaoNeiDemo {  

public static void main(String[] argv) {  
//login  
URL url = null;  
HttpURLConnection urlConnection = null;  
try {  
url = new URL("http://www.renren.com/PLogin.do");  

urlConnection = (HttpURLConnection) url.openConnection();  
urlConnection.setRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
urlConnection.setRequestProperty("Pragma:", "no-cache");
urlConnection.setRequestProperty("Cache-Control", "no-cache");
urlConnection.setDoInput(true);  

urlConnection.setDoOutput(true);  

urlConnection.setRequestMethod("POST");  

OutputStream out = urlConnection.getOutputStream();  
String user = "529590568@qq.com";  
String passwd = "ZHANGFUYU1990";  
String logParam = "email=" + user + "&password=" + passwd + "&origURL=http://www.renren.com/home&domain=renren.com&isplogin=true"; 
System.out.println(logParam);
out.write(logParam.getBytes());  
out.flush();  
out.close();  

BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));  
while(in.read() != -1) { 
	
System.out.println(new String(in.readLine().getBytes(),"UTF-8"));  
}  
} catch (MalformedURLException e) {  
// TODO Auto-generated catch block  
e.printStackTrace();  
} catch (IOException e) {  
// TODO Auto-generated catch block  
e.printStackTrace();  
}  

//ip  

}  
}